/************************************************************\
 Presidential Quiz by Joe Barta - HTMLisEasy.com
 Permission is granted to freely use/modify this code.
\************************************************************/

function isThatYourFinalAnswer()
{
   var incorrect_answers = 0;
   var hint_pieces = "";

   if ((window.document.presquiz.elements[0].checked  == false)||(window.document.presquiz.elements[1].checked  == true )) { incorrect_answers++; hint_pieces = hint_pieces + "George W. Bush is a Republican\n"; }
   if ((window.document.presquiz.elements[2].checked  == true )||(window.document.presquiz.elements[3].checked  == false)) { incorrect_answers++; hint_pieces = hint_pieces + "Bill Clinton was a Democrat\n"; }
   if ((window.document.presquiz.elements[4].checked  == false)||(window.document.presquiz.elements[5].checked  == true )) { incorrect_answers++; hint_pieces = hint_pieces + "George H.W. Bush was a Republican\n"; }
   if ((window.document.presquiz.elements[6].checked  == false)||(window.document.presquiz.elements[7].checked  == true )) { incorrect_answers++; hint_pieces = hint_pieces + "Ronald Reagan was a Republican\n"; }
   if ((window.document.presquiz.elements[8].checked  == true )||(window.document.presquiz.elements[9].checked  == false)) { incorrect_answers++; hint_pieces = hint_pieces + "Jimmy Carter was a Democrat\n"; }
   if ((window.document.presquiz.elements[10].checked == false)||(window.document.presquiz.elements[11].checked == true )) { incorrect_answers++; hint_pieces = hint_pieces + "Gerald Ford was a Republican\n"; }
   if ((window.document.presquiz.elements[12].checked == false)||(window.document.presquiz.elements[13].checked == true )) { incorrect_answers++; hint_pieces = hint_pieces + "Richard Nixon was a Republican\n"; }
   if ((window.document.presquiz.elements[14].checked == true )||(window.document.presquiz.elements[15].checked == false)) { incorrect_answers++; hint_pieces = hint_pieces + "Lyndon Johnson was a Democrat\n"; }
   if ((window.document.presquiz.elements[16].checked == true )||(window.document.presquiz.elements[17].checked == false)) { incorrect_answers++; hint_pieces = hint_pieces + "John F. Kennedy was a Democrat\n";}
   if ((window.document.presquiz.elements[18].checked == false)||(window.document.presquiz.elements[19].checked == true )) { incorrect_answers++; hint_pieces = hint_pieces + "Dwight Eisenhower was a Republican\n"; }
   if ((window.document.presquiz.elements[20].checked == true )||(window.document.presquiz.elements[21].checked == false)) { incorrect_answers++; hint_pieces = hint_pieces + "Harry Truman was a Democrat\n"; }
   if ((window.document.presquiz.elements[22].checked == true )||(window.document.presquiz.elements[23].checked == false)) { incorrect_answers++; hint_pieces = hint_pieces + "Franklin Roosevelt was a Democrat\n";}//Herbert Hoover was a Republican\n

   var hint1 = "Here is a hint...\n\n"      + hint_pieces + "\nAdjust your answers and click the link again";
   var hint2 = "Here are a couple hints...\n\n" + hint_pieces + "\nAdjust your answers and click the link again";
   var hint3 = "Here are a few hints...\n\n"    + hint_pieces + "\nAdjust your answers and click the link again";

   if((window.document.presquiz.elements[0].checked  == false)&&(window.document.presquiz.elements[1].checked  == false)&&(window.document.presquiz.elements[2].checked  == false)&&(window.document.presquiz.elements[3].checked  == false)&&(window.document.presquiz.elements[4].checked  == false)&&(window.document.presquiz.elements[5].checked  == false)&&(window.document.presquiz.elements[6].checked  == false)&&(window.document.presquiz.elements[7].checked  == false)&&(window.document.presquiz.elements[8].checked  == false)&&(window.document.presquiz.elements[9].checked  == false)&&(window.document.presquiz.elements[10].checked  == false)&&(window.document.presquiz.elements[11].checked  == false)&&(window.document.presquiz.elements[12].checked  == false)&&(window.document.presquiz.elements[13].checked  == false)&&(window.document.presquiz.elements[14].checked  == false)&&(window.document.presquiz.elements[15].checked  == false)&&(window.document.presquiz.elements[16].checked  == false)&&(window.document.presquiz.elements[17].checked  == false)&&(window.document.presquiz.elements[18].checked  == false)&&(window.document.presquiz.elements[19].checked  == false)&&(window.document.presquiz.elements[20].checked  == false)&&(window.document.presquiz.elements[21].checked  == false)&&(window.document.presquiz.elements[22].checked  == false)&&(window.document.presquiz.elements[23].checked  == false))
   {
      alert("You\'re not even gonna try? At least click a thing or two.");
   }
   else
   {
      if(incorrect_answers == 0)
      {
         alert("All correct. Very good!");
      }

      if(incorrect_answers == 1)
      {
         if (confirm("Doh! Missed one. Still, not bad. Would you like some help?"))
         {
            alert(hint1)
         }
      }

      if(incorrect_answers == 2)
      {
         if (confirm("Bummer. Missed two. Would you like some help?"))
         {
            alert(hint2)
         }
      }

      if((incorrect_answers == 3)||(incorrect_answers == 4)||(incorrect_answers == 5)||(incorrect_answers == 6)||(incorrect_answers == 7)||(incorrect_answers == 8))
      {
         if (confirm("Missed a few. Would you like some help?"))
         {
            alert(hint3)
         }
      }

      if(incorrect_answers > 8)
      {
         if (confirm("Oh my. You didn\'t do so well. Would you like some help?"))
         {
            alert(hint3)
         }
      }
   }
}
